<template>
    <div class="boxkung">
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <el-menu-item index="0">{{$t('basicinfoofmer')}}</el-menu-item>
            <el-menu-item index="1">{{$t('settleinfo')}}</el-menu-item>
            <el-menu-item index="2">{{$t('meradmininfo')}}</el-menu-item>
            <el-menu-item index="3">{{$t('mersecretkey')}}</el-menu-item>
            <el-menu-item index="4">{{$t('loginpwd')}}</el-menu-item>
            <el-menu-item index="5">{{$t('loginlog')}}</el-menu-item>
            <el-menu-item index="6">{{$t('deviceinfo')}}</el-menu-item>
            <!-- <el-button type="primary" icon="el-icon-d-arrow-left" :circle="true" @click="goAway"></el-button> -->
        </el-menu>
        <router-view></router-view>
    </div>
</template>

<script>
export default {
    data() {
        return {
         menu: [
                '/sec/merManage/merDetail/baseInfo',
                '/sec/merManage/merDetail/settleInfo',
                '/sec/merManage/merDetail/accountInfo',
                '/sec/merManage/merDetail/secretKey',
                '/sec/merManage/merDetail/loginPwd',
                '/sec/merManage/merDetail/loginRecord',
                '/sec/merManage/merDetail/deviceInfo'
            ],
            activeIndex: '0',
            merId: ''
        }
    },
    methods: {
        handleSelect (key, keyPath) {
            window.sessionStorage.setItem('kidx', key)
            // 导航栏选中，页面跳转
            this.$router.push(this.menu[key])
        },
        goAway () {
             // 返回商户列表
             window.sessionStorage.removeItem('kidx')
            this.$router.push('/merManage/merList')
        }
    },
    mounted() {
        if (window.sessionStorage.getItem('kidx')) {
            this.activeIndex = window.sessionStorage.getItem('kidx')
            this.$router.push(this.menu[this.activeIndex - 0])
        } else {
            this.activeIndex = '0'
            this.$router.push(this.menu[0])
        }
        this.merId = this.$store.state.merId
    },
    destroyed () {
        window.sessionStorage.removeItem('merStatus')
        window.sessionStorage.removeItem('mercretime')
        window.sessionStorage.removeItem('merId')
        window.sessionStorage.removeItem('mername')
        window.sessionStorage.removeItem('merusername')
        window.sessionStorage.removeItem('kidx')
    }
}
</script>

<style lang="less" scoped>
@import './merDetail.less';
</style>
